<template>
    <div>
        <div class="crumbs">
            <el-breadcrumb separator="/">
                <el-breadcrumb-item>
                    <!-- <div class="indexTitle">楼幢管理</div> -->
                    <div class="contentsize">房产招租中预警</div>
                </el-breadcrumb-item>
            </el-breadcrumb>
        </div>
        <div class="container">
            <div class="handle-box">
                <el-form ref="form" :model="form" label-width="80px" :inline="true" size="mini">
                    <el-form-item label="房屋地址:">
                        <div style="width:190px">
                            <el-input v-model="form.fwdz" placeholder="请输入房屋地址"></el-input>
                        </div>
                    </el-form-item>
                    <el-form-item label="租户姓名:">
                        <div style="width:190px">
                            <el-input v-model="form.mh" placeholder="请输入租户姓名"></el-input>
                        </div>
                    </el-form-item>
                    <el-form-item label="合同编号:">
                        <div style="width:190px">
                            <el-input v-model="form.lc" placeholder="请输入合同编号"></el-input>
                        </div>
                    </el-form-item>
                    <el-form-item label="产权单位:">
                        <div style="width:190px">
                            <el-input v-model="form.dabh" placeholder="请输入产权单位"></el-input>
                        </div>
                    </el-form-item>
                    <el-form-item>
                        <el-button type="primary" @click="onSearch" icon="el-icon-search" class="searchcolor">查询</el-button>
                    </el-form-item>
                    <!-- <el-form-item>
                        <el-button type="primary" @click="addnew" icon="el-icon-plus" class="addcolor">添加</el-button>
                    </el-form-item> -->
                </el-form>
            </div>
            <el-table :data="tableData" style="width: 100%" :header-cell-style="tableHeaderColor" :row-style="tablerowColor"
                border>
                <el-table-column prop="name" label="房产编号" align="center"> </el-table-column>
                <el-table-column prop="address" label="房屋地址" align="center"> </el-table-column>
                <el-table-column prop="address" label="单元" align="center"> </el-table-column>
                <el-table-column prop="address" label="房间" align="center"> </el-table-column>
                <el-table-column prop="address" label="租户姓名" align="center"> </el-table-column>
                <el-table-column prop="address" label="到期时间" align="center"> </el-table-column>
                <el-table-column prop="address" label="产权单位" align="center"> </el-table-column>
                <el-table-column fixed="right" label="操作" width="180" align="center">
                    <template slot-scope="scope">
                        <router-link :to="{ name: 'projectdetail', params: { id: scope.row.id } }"
                            style="padding-right: 12px">
                            <el-button type="text" size="small">编辑</el-button>
                        </router-link>
                        <router-link :to="{ name: 'editproject', params: { id: scope.row.id } }"
                            style="padding-right: 12px">
                            <el-button type="text" size="small">退租</el-button>
                        </router-link>
                        <!-- <el-button type="text" size="small" @click="deleteClick(scope.row)"
                            style="color: red">删除</el-button> -->
                    </template>
                </el-table-column>
            </el-table>
            <div class="pagination" style="float: right">
                <el-pagination background layout="total,prev, pager, next,jumper" :total="total" :current-page.sync="current"
                    :page-size="pageSize" @current-change="handleCurrentChange">
                </el-pagination>
            </div>
        </div>
    </div>
</template>

<script>
import axios from 'axios';
import { projectList, projectdelete } from '@/api/index';
export default {
    name: 'qtyjlist',
    data() {
        return {
            total: 0,
            current: 1,
            pageSize: 10,
            form: {
                address: '', //项目地址
                beginTime: '', //开工时间
                completionTime: '', //竣工时间
                current: 1, //第几页
                name: '', //项目名称
                pageSize: 10 //每页数量
            },
            tableData: [],
            
            hxlist:[{ name: '全部', code: '全部' }, { name: '一室一厅', code: '一室一厅' }, { name: '二室一厅', code: '二室一厅' }, { name: '二室二厅', code: '二室二厅' }, { name: '三室二厅', code: '三室二厅' }, { name: '其他', code: '其他' }]//户型
        };
    },
    components: {},
    computed: {},
    methods: {
        // 列表样式
        tableHeaderColor({ row, column, rowIndex, columnIndex }) {
            if (rowIndex === 0) {
                return 'background-color: #f7f7f7;color:black;height: 54px;font-weight: 500;font-size:14px;font-variant:tabular-nums'
            }
        },
        tablerowColor({ row, rowIndex }) {
            return 'height: 42px;font-size:14px;'
        },
        // 换页
        handleCurrentChange(val) {
            this.current = val;
            this.form.current = val;
            this.projectList(this.form);
            console.log(val);
        },
        // 搜索
        onSearch() {
            this.current = 1;
            this.form.current = 1;
            this.projectList(this.form);
            console.log('搜索');
        },
        // 添加
        addnew() {
            this.$router.push({
                name: 'adddy',
                path: '/adddy'
            });
        },
        // 删除
        deleteClick(e) {
            console.log(e);
            this.$confirm('确定删除此条信息吗？')
                .then(() => {
                    let data = { id: e.id };
                    projectdelete(data).then((res) => {
                        if (res.code == 200) {
                            this.projectList(this.form);
                            this.$message.success('删除成功');
                        }
                    });
                })
                .catch(() => {
                    this.$message.success('删除取消');
                });
        },
        // 项目列表
        projectList(data) {
            projectList(data).then((res) => {
                if (res.code == 200) {
                    this.tableData = res.data.records;
                    this.total = res.data.total;
                } else {
                    this.tableData = [];
                    this.total = 0;
                }
            });
        }
    },
    mounted() {
        this.projectList(this.form);
    }
};
</script>

<style scoped>
.container {
    overflow: hidden;
}

.crumbs {
    background-color: #fff;
    padding: 20px 20px;
}

.indexTitle {
    margin-bottom: 20px;
}

.contentsize {
    font-size: 18px;
    font-weight: 700;
}

.handle-box {
    overflow: hidden;
}

/* 新增按钮 */
.addcolor {
    margin-bottom: 10px;
}
</style>
